﻿using CommunityToolkit.Mvvm.ComponentModel;
using Koala.Pro.Common;
using Koala.Pro.Core.Dto;
using Koala.Pro.Core.Models;
using Koala.Pro.Services;

namespace Koala.Pro.ViewModels
{
    public partial class UserEditViewModel : BaseEditViewModel<UserInfo, int, UserPagedDto>
    {
        [ObservableProperty]
        private List<FunctionInfo> functionInfos = new List<FunctionInfo>();

        [ObservableProperty]
        private List<MenuInfo> menuInfos = new List<MenuInfo>();

        public UserEditViewModel(IUserService service)
            : base(service)
        {
            base.Title = "用户信息";
        }

        public async Task InitData(int id)
        {
            string systemType = App.ViewModel.SystemType;
            FunctionInfos = await BLLFactory<IFunctionService>.Instance.GetFunctionNodesByUser(id, systemType);
            MenuInfos = await BLLFactory<IMenuService>.Instance.GetMenuNodesByUser(id, systemType);
        }
    }
}
